{include file="public/header" /}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }

    #id {
        width: 78px;
    }

    .bs-checkbox {
        width: 36px;
        height: 40px
    }

    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }

    #title span {
        float: right;
    }

    .btn-active {
        background: #1ab394;
        color: #fff
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <form class="form-horizontal" method="post">

            <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">

                    <div style="display:block;clear: both;"></div>
                    <div class="fixed-table-toolbar">

                    </div>
                    <div class="example">
                        <form class="form-horizontal" method="post">



                            <!--推广奖start-->
                            {foreach $sexs as $key=>$val}

                            <div class="form-group-title">{$val}士推广奖    {if $development_display}<span style="color: red;">推广奖：extension[val][上级性别即{$key}][上级代数][下级性别]，上级是否vip：extension[is_vip][上级性别即{$key}][上级代数]，上级是否需要实名：extension[is_realname][上级性别即{$key}][上级代数]，总代数：extension[g][上级性别即{$key}]</span>{/if}
                            </div>
                            <table data-toggle="table"  id="extension_table_{$key}">
                                <!--red_table_上级性别-->
                                {php}
                                    $g = compare_val($extension['g'][$key],0)?0:$extension['g'][$key];
                                    $g = $g?:0;
                                {/php}
                                <!--默认代数-->
                                <input type="hidden" name="extension[g][{$key}]" value="{$g}" id="extension_num_{$key}" />

                                <h4 style="padding: 0 0px 10px 10px;">
                                    <a href="javascript:;" onclick="addOptions('extension_table_{$key}',{$key});" title="添加代数" class="btn btn-primary"><i class="fa fa-plus"></i> 添加代数</a>
                                    <a href="javascript:;" onclick="removeOptions('extension_table_{$key}',{$key});" title="删除代数" class="btn btn-primary"><i class="fa fa-remove"></i> 删除代数</a>
                                </h4>
                                <thead>
                                <tr>
                                    <th data-align="center">代数</th>
                                    {foreach $sexs as $k=>$v}
                                    <th data-align="center">推荐{$v}士奖励</th>
                                    {/foreach}
                                    <th data-align="center">上级是否VIP</th>
                                    <th data-align="center">上级是否需要实名</th>

                                </tr>
                                </thead>
                                <tbody id="form">
                                {for start="1" end="$g+1"}
                                    <!--tjj_num_上级性别_第几代-->
                                    <tr class="class" id="extension_num_{$key}_{$i}">
                                        <td>{$i}代</td>
                                        {foreach $sexs as $k_td=>$v_td}

                                        <td><input type="text" name="extension[val][{$key}][{$i}][{$k_td}]" class="form-control" value="<?php echo compare_val($extension['g'][$key],0)?'':$extension['val'][$key][$i][$k_td];?>" /></td>
                                        {/foreach}

                                        <td>
                                            <input type="radio" name="extension[is_vip][{$key}][{$i}]" value="1"
                                                   {if radio_checked($extension['is_vip'][$key][$i],1)}checked="checked"{/if} /> 是
                                            <input type="radio" name="extension[is_vip][{$key}][{$i}]" value="0"
                                                   {if radio_checked($extension['is_vip'][$key][$i],0)}checked="checked"{/if}
                                            /> 否
                                        </td>

                                        <td>
                                            <input type="radio" name="extension[is_realname][{$key}][{$i}]" value="1"
                                                   {if radio_checked($extension['is_realname'][$key][$i],1)}checked="checked"{/if} /> 需要
                                            <input type="radio" name="extension[is_realname][{$key}][{$i}]" value="0"
                                                   {if radio_checked($extension['is_realname'][$key][$i],0)}checked="checked"{/if}
                                            /> 不需要
                                        </td>
                                    </tr>
                                {/for}



                                </tbody>
                            </table>
                            <hr>
                            {/foreach}
                            <!--推广奖end-->
                    </div>
                </div>
            </div>
            <hr>


        </div>
        </form>
    </div>
</div>
{include file="public/footer" /}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.css"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table.min.js"}
{load href="__STYLE__/admin/plugins/bootstrap/bootstrap-table-zh-CN.min.js"}
{load href="__STYLE__/admin/plugins/iCheck/custom.css"}
{include file="public/bottom" /}

<script language="javascript">
    function addOptions(table,key){
        var sex_name = key==1?'男':'女';
        var num = parseInt($('#extension_num_'+key).val());
        if(num == 0){
            $('#extension_table_'+key+' .no-records-found').remove();
        }
        var new_num = num + 1;
        // tjj_num_上级性别_第几代
        var html = '<tr class="class" id="extension_num_'+key+'_'+new_num+'">'+
                        '<td style="text-align: center; ">'+new_num+'代</td>';

        {volist name="sexs" id="vo"}
            html +=     '<td style="text-align: center; ">' +
                            '<input type="text" name="extension[val]['+key+']['+new_num+'][{$key}]" class="form-control" value="" />' +
                        '</td>';
        {/volist}
            html +=     '<td style="text-align: center; ">'+
                '<input type="radio" name="extension[is_vip]['+key+']['+new_num+']" value="1" /> 是' +
                '<input type="radio" name="extension[is_vip]['+key+']['+new_num+']" value="0" checked="checked" /> 否' +
                '</td>';
            html +=     '<td style="text-align: center; ">'+
                            '<input type="radio" name="extension[is_realname]['+key+']['+new_num+']" value="1" /> 需要' +
                            '<input type="radio" name="extension[is_realname]['+key+']['+new_num+']" value="0" checked="checked" /> 不需要' +
                        '</td>' +
                  '</tr>';

            $('#extension_table_'+key).append(html);
            if(new_num >= 0){
                $('#extension_num_'+key).val(new_num)
            }
        }

        //删除最后的一代
        function removeOptions(table,key){
            var num = parseInt($('#extension_num_'+key).val());
            var new_num = num - 1;

            $('#extension_num_'+key+'_'+num).remove();
            if(new_num >= 0){
                $('#extension_num_'+key).val(new_num)
            }
            if(new_num == 0){
                $('#extension_num_'+key).val(new_num);
                var html = '<tr class="no-records-found"><td colspan="{$sex_num+2}">没有找到匹配的记录</td></tr>';
                $('#extension_table_'+key).append(html);
            }
        }

</script>